import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  ProductPerformanceParentAsinVO,
  ProductPerformanceParentAsinForm,
  ProductPerformanceParentAsinQuery
} from '@/api/lingxing/productPerformanceParentAsin/types';

/**
 * 查询领星产品现-父ASIN列表
 * @param query
 * @returns {*}
 */

export const listProductPerformanceParentAsin = (query?: ProductPerformanceParentAsinQuery): AxiosPromise<ProductPerformanceParentAsinVO[]> => {
  return request({
    url: '/lingxing/productPerformanceParentAsin/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询领星产品现-父ASIN详细
 * @param id
 */
export const getProductPerformanceParentAsin = (id: string | number): AxiosPromise<ProductPerformanceParentAsinVO> => {
  return request({
    url: '/lingxing/productPerformanceParentAsin/' + id,
    method: 'get'
  });
};

/**
 * 新增领星产品现-父ASIN
 * @param data
 */
export const addProductPerformanceParentAsin = (data: ProductPerformanceParentAsinForm) => {
  return request({
    url: '/lingxing/productPerformanceParentAsin',
    method: 'post',
    data: data
  });
};

/**
 * 修改领星产品现-父ASIN
 * @param data
 */
export const updateProductPerformanceParentAsin = (data: ProductPerformanceParentAsinForm) => {
  return request({
    url: '/lingxing/productPerformanceParentAsin',
    method: 'put',
    data: data
  });
};

/**
 * 删除领星产品现-父ASIN
 * @param id
 */
export const delProductPerformanceParentAsin = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lingxing/productPerformanceParentAsin/' + id,
    method: 'delete'
  });
};

/**
 * 同步领星接口
 * @returns {*}
 */
export const syncData = (data?: ProductPerformanceParentAsinQuery) => {
  return request({
    url: '/lingxing/productPerformanceParentAsin/syncData',
    method: 'post',
    data: data
  });
};

export const getNewestUpdateTime = () => {
  return request({
    url: '/lingxing/productPerformanceParentAsin/getNewestUpdateTime',
    method: 'get'
  });
};
